<?php

class allChipsModule extends Module {
	/*
	 * 在构造函数中装载所依赖的类或其他文件
	*/
	function __construct() {
		$this->includePhp('allChips', 'allChips');
	}
	
	
	/*
	 * 调用插件资源
	*/
	public function call($user, $method, $param) {
		switch ($method) {
			case "winlist":
			    $pid = $param->pid;                //商品id
				if (!isset($pid)) {
					Output::instance()->resultCode(code_lackof_param);
					return;
				}
			    allChips::getWinList($pid);
			    break;
			case "getHistoryList":
				$periodId = $param->periodId; //期ID
				$start = $param->start;			//开始位置
				$limit = $param->limit;				//查询数量
				if (!isset($periodId)||!isset($start)||!isset($limit)) {
					Output::instance()->resultCode(code_lackof_param);
					return;
				}
				allChips::buyHistoryList($periodId,$start,$limit);
				break;
			case "createParRecord":
				$periodId = $param->periodId; //期ID
				$oid = $param->oid;  //订单ID
				$pid = $param->pid;   //商品ID
				$count = $param->count;  //参与人次
				$periodCount = $param->periodCount;  //参与期次
				$openId = $param->fromOpenId;   //来自分享人的openid
				if (!isset($periodId)||!isset($oid)||!isset($pid)||!isset($count)||!isset($periodCount)) {
					Output::instance()->resultCode(code_lackof_param);
					return;
				}
				allChips::createParRecord($periodId,$oid,$pid,$count,$periodCount,$openId);
				break;
			case "indianaSuccess":
				$parId = $param->parId;  //参与ID
				if (!isset($parId)) {
					Output::instance()->resultCode(code_lackof_param);
					return;
				}
				allChips::indianaSuccess($parId);
				break;
			case "graphicDetail":
				$pid = $param->pid;  //商品ID
				if (!isset($pid)) {
					Output::instance()->resultCode(code_lackof_param);
					return;
				}
				allChips::graphicDetail($pid);
				break;
			case "calculation":
				$perId = $param->perId;  //期ID
				if (!isset($perId)) {
					Output::instance()->resultCode(code_lackof_param);
					return;
				}
				allChips::calculation($perId);
				break;
			case "getIndianaDetail":
				$oid = $param->oid;  //订单ID
				if (!isset($oid)) {
					Output::instance()->resultCode(code_lackof_param);
					return;
				}
				allChips::indianaDetail($oid);
				break;
			case "newAnnounced":
				allChips::newAnnounced();
				break;
		}
	}
}


$module = new allChipsModule();
Module::addModule($module);
?>